package com.yonyou.jrmob.contacts.schedule.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yonyou.jrmob.contacts.R;
import com.yonyou.jrmob.contacts.schedule.vo.MeetRoomVO;

import java.util.List;

/**
 *会议室适配器
 */
public class BoardroomAdapter extends BaseAdapter {

    private List<MeetRoomVO> list;
    private Context context;

    public BoardroomAdapter(Context context, List<MeetRoomVO> list) {
        this.list = list;
        this.context = context;
    }

    @Override
    public int getCount() {
        if (null == list) {
            return 0;
        }
        return list.size();
    }

    @Override
    public MeetRoomVO getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = View.inflate(context, R.layout.scheduleremind_item, null);
            holder.remain_name = (TextView) convertView.findViewById(R.id.remain_name);
            holder.remain_time = (TextView) convertView.findViewById(R.id.remain_time);
            holder.remind_line = (TextView) convertView.findViewById(R.id.remind_line);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

        MeetRoomVO vo = list.get(position);
        if (vo.getIsusAble().equals("0")) {
            holder.remain_name.setTextColor(convertView.getResources().getColor(R.color.black));
        } else {
            holder.remain_name.setTextColor(convertView.getResources().getColor(R.color.grey_a3));
        }
        holder.remain_name.setText(vo.getRoonNo());
        return convertView;
    }
    class ViewHolder {
        TextView remain_name;
        TextView remain_time;
        TextView remind_line;
    }

}

